package net.zjitc.dao.impl;

import net.zjitc.dao.OrderDao;
import net.zjitc.pojo.Evaluate;
import net.zjitc.pojo.Orderitem;
import net.zjitc.pojo.Orders;
import net.zjitc.utils.db.C3P0Utils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

/**
 * Created by Administrator on 2017/12/24.
 */
public class OrderDaoImpl implements OrderDao {
    @Override
    public List<Orderitem> findOrderitemAll() {
        QueryRunner runner=new QueryRunner(C3P0Utils.getDataSource());
        String sql="select * from orderitem";
        try {
            List<Orderitem> list= (List<Orderitem>) runner.query(sql,new BeanListHandler(Orderitem.class));
            return list;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public List<Evaluate> findEvaluateAll() {
        QueryRunner runner=new QueryRunner(C3P0Utils.getDataSource());
        String sql="select * from evaluate";
        try {
            List<Evaluate> list= (List<Evaluate>) runner.query(sql,new BeanListHandler(Evaluate.class));
            return list;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public List<Orders> findOrderAll() {
        QueryRunner runner=new QueryRunner(C3P0Utils.getDataSource());
        String sql="select * from orders";
        try {
            List<Orders> list= (List<Orders>) runner.query(sql,new BeanListHandler(Orders.class));
            return list;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}
